﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Simulation
{
	class C_SEFF
	{
		int[] keys;

		F_SETT ST = new F_SETT();
		F_BSKS KS = new F_BSKS();		
		
		Random R = new Random( ( int )DateTime.Now.Ticks );

		public int SetPID()
		{
			return R.Next( 0, ST.OSPID - 1 );
		}

		public int[] SetKeys( int pid )
		{
			keys = new int[ST.OKYDS];
			int col = -1;

			for ( int i = 0; i < ST.OKYDS; i++ )
			{
				col		= -1 ;
				col		= CheckOverlapKey( R.Next( 0, ST.OSKEY) );
				keys[i]	= KS.OSKEY[pid, col];
			}
			return keys;
		}

		public int CheckOverlapKey( int tmp )
		{
			for ( int i = 0; i < ST.OKYDS; i++ )
			{
				if ( keys[i] == tmp )
				{
					tmp = R.Next( 0, ST.OSKEY );
					CheckOverlapKey( tmp );
				}
			}

			return tmp;
		}

		public string SetStringKey( int[] K )
		{
			string keys = null;

			for ( int i = 0; i< ST.OKYDS; i++ )
			{
				keys = keys + K[i].ToString();
				
				if ( i != ST.OKYDS - 1 )
					keys = keys + "-";
			}

			return keys;
		}

		public int DropFalseReport( int c )
		{
			return c++;
		}

	}
}
